package com.tentact.web1216.servlets;

import service.StudentService;
import vo.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SelectDepatServlet", value = "/SelectDepatServlet")
public class SelectDepatServlet extends HttpServlet {

    private StudentService service =new StudentService();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Student student=new Student();
        String name=request.getParameter("name");
        int clazzid=Integer.parseInt(request.getParameter("clazzid"));
        if (name!=null){
            student.setName(name);
        }else{
            name="";
        }
        if (clazzid!=0){
            student.setClazzid(clazzid);

        }
        List<Student> students=service.selectStudent(student);
        request.setAttribute("students",students);
        request.getRequestDispatcher("StudentView.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
